<?php
class Customer_Model_Users extends TBB_Model_Users
{	
	/**
	 * Register account (only used for customer module)
	 * @param string $username
	 * @param string $password
	 * @param string $fullName
	 * @param string $email
	 * @param string $ssn
	 * @param string $mobile
	 * @return unknown
	 */
	public function registerUserAccount($username, $password, $fullName, $email, $ssn, $mobile)
	{
		$db = Zend_Db_Table::getDefaultAdapter();
		$db->beginTransaction();
		try {
			// first create customer
			$customerModel = new Customer_Model_Customer();	
			$customerID = $customerModel->createCustomer($fullName, $email, $ssn, $mobile); 

			// second create user
			$userID = $this->_createUser($username, $password, $customerID);
			
			// add customer role ID
			$roleModel = new Customer_Model_Role();
			$customerRoleID = $roleModel->getCustomerRoleID();	

			// finally create roles for the user
			$this->_createRolesForUser($userID, array($customerRoleID));
					
			$db->commit();			
			return $userID;
		} catch(Exception $e) {
			$db->rollBack();
			throw $e;
		}
	}
}